PDBGEN_BACKUP = 0
PDBGEN_GROUPS =

pdb_groups = \
	groups/brush.pdb		\
	groups/brush_select.pdb		\
	groups/brushes.pdb		\
	groups/buffer.pdb		\
	groups/channel.pdb		\
	groups/context.pdb		\
	groups/debug.pdb		\
	groups/display.pdb		\
	groups/drawable.pdb		\
	groups/drawable_color.pdb	\
	groups/drawable_edit.pdb	\
	groups/dynamics.pdb		\
	groups/edit.pdb			\
	groups/file.pdb			\
	groups/floating_sel.pdb		\
	groups/font_select.pdb		\
	groups/fonts.pdb		\
	groups/gimp.pdb			\
	groups/gimprc.pdb		\
	groups/gradient.pdb		\
	groups/gradient_select.pdb	\
	groups/gradients.pdb		\
	groups/help.pdb			\
	groups/image.pdb		\
	groups/image_color_profile.pdb	\
	groups/image_convert.pdb	\
	groups/image_grid.pdb		\
	groups/image_guides.pdb		\
	groups/image_sample_points.pdb	\
	groups/image_select.pdb		\
	groups/image_transform.pdb	\
	groups/image_undo.pdb		\
	groups/item.pdb			\
	groups/item_transform.pdb	\
	groups/layer.pdb		\
	groups/message.pdb		\
	groups/paint_tools.pdb		\
	groups/palette.pdb		\
	groups/palette_select.pdb	\
	groups/palettes.pdb		\
	groups/pattern.pdb		\
	groups/pattern_select.pdb	\
	groups/patterns.pdb		\
	groups/pdb.pdb			\
	groups/plug_in.pdb		\
	groups/plug_in_compat.pdb	\
	groups/progress.pdb		\
	groups/selection.pdb		\
	groups/text_layer.pdb		\
	groups/text_tool.pdb		\
	groups/unit.pdb			\
	groups/vectors.pdb

EXTRA_DIST = \
	README			\
	README_NEW_PDB_PROC	\
	app.pl			\
	enumcode.pl		\
	enumgen.pl		\
	enums.pl		\
	enums-external.pl	\
	groups.pl		\
	lib.pl			\
	pdb.pl			\
	pdbgen.pl		\
	stddefs.pdb		\
	util.pl			\
	$(pdb_groups)

enum_headers = \
	../libgimpbase/gimpbaseenums.h		\
	../libgimpconfig/gimpconfigenums.h	\
	../app/operations/operations-enums.h	\
	../app/core/core-enums.h		\
	../app/paint/paint-enums.h

pdb_scripts = \
	pdbgen.pl	\
	stddefs.pdb	\
	pdb.pl		\
	util.pl		\
	enums.pl	\
	groups.pl

enum_deps = \
	enums.pl		\
	$(srcdir)/util.pl

pdbgen_deps = \
	$(enum_deps)		\
	$(srcdir)/app.pl	\
	$(srcdir)/lib.pl	\
	$(srcdir)/pdb.pl	\
	$(srcdir)/stddefs.pdb	\
	$(srcdir)/pdbgen.pl

stamp_files = \
	stamp-enums		\
	stamp-groups		\
	stamp-pdbgen		\
	stamp-enum-code		\
	stamp-enum-code-py

DISTCLEANFILES = $(stamp_files)

$(srcdir)/enums.pl: stamp-enums
	@:
stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) enums-external.pl Makefile.am
	rootme=`pwd`; \
	destdir=`cd $(top_srcdir) && pwd`; export destdir; \
	builddir=`cd $(top_builddir) && pwd`; export builddir; \
	cd $(srcdir) && $(PERL) enumgen.pl $(enum_headers) \
	&& echo timestamp > $$rootme/stamp-enums

$(srcdir)/groups.pl: stamp-groups
	@:
stamp-groups: Makefile.am
	rootme=`pwd`; cd $(srcdir) \
	&& echo "# This file is autogenerated" > $$rootme/groups.pl.tmp \
	&& echo "@groups = qw(" >> $$rootme/groups.pl.tmp \
	&& (for pdb in $(pdb_groups); do \
	      group=`echo $$pdb | sed -e 's%groups/\([^.]*\)\..*%\1%'`; \
	      echo "    $$group" >> $$rootme/groups.pl.tmp; \
	    done) \
	&& echo ");" >> $$rootme/groups.pl.tmp \
	&& (cmp -s $$rootme/groups.pl.tmp groups.pl || \
            cp $$rootme/groups.pl.tmp groups.pl) \
	&& rm $$rootme/groups.pl.tmp \
	&& echo timestamp > $$rootme/stamp-groups

stamp-pdbgen: $(pdbgen_deps) $(pdb_scripts) $(pdb_groups) Makefile.am
	rootme=`pwd`; \
	destdir=`cd $(top_srcdir) && pwd`; export destdir; \
	builddir=`cd $(top_builddir) && pwd`; export builddir; \
	cd $(srcdir) && \
	   PDBGEN_BACKUP=$(PDBGEN_BACKUP) PDBGEN_GROUPS=$(PDBGEN_GROUPS) \
	   $(PERL) pdbgen.pl app lib \
	&& echo timestamp > $$rootme/stamp-pdbgen

stamp-enum-code: $(srcdir)/enumcode.pl $(enum_deps)
	rootme=`pwd`; \
	destdir=`cd $(top_srcdir) && pwd`; export destdir; \
	builddir=`cd $(top_builddir) && pwd`; export builddir; \
	cd $(srcdir) && \
	  PDBGEN_BACKUP=$(PDBGEN_BACKUP) \
	  $(PERL) enumcode.pl \
	 && echo timestamp > $$rootme/stamp-enum-code

all-local: stamp-pdbgen stamp-enum-code
